package cn.gok.mapper;

import cn.gok.pojo.Dentity;
import cn.gok.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    @Select("SELECT * FROM user WHERE username=#{username} AND `password`=#{password}")
    public User login(String username,String password);

    @Select("show databases")
    public List<String> link();

    @Select("SELECT * FROM dentity WHERE dentity_num=#{dentity_id}")
    public Dentity seldentity(Integer dentity_id);

    @Insert("INSERT INTO `user`(username,password)VALUES(#{username},#{password})")
    public int registered(String username,String password);

    @Select("SELECT * FROM `user`")
    public List<User> selall();

    public List<User> selof(@Param("query") String query);

    @Delete("DELETE FROM `user` where username=#{query}")
    public int del(@Param ("query")  String query);

    @Update("UPDATE `user` SET username=#{user.username},password=#{user.password},dentity_id=#{user.dentity_id}  where id=#{user.id}")
    public int change(@Param ("user") User user);

    @Select("SELECT * from dentity")
    public List<Dentity> selalldentity();
}
